﻿<UserControl x:Class="MyImdb.Views.SearchLocalView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
             xmlns:converters="clr-namespace:MyImdb.Converters"
             mc:Ignorable="d"
             d:DesignHeight="600"
             d:DesignWidth="800">

    <UserControl.Resources>
        <converters:LocalPosterUrlConverter x:Key="LocalPosterUrl" />
        <converters:StringUpperCaseConverter x:Key="StringUpperCase" />
        <converters:ImdbDateToDateTimeConverter x:Key="ImdbDateToDateTime" />
    </UserControl.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="38" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <ComboBox HorizontalAlignment="Center"
                  VerticalAlignment="Center"
                  ItemsSource="{Binding ImdbTitles}"
                  Controls:TextboxHelper.Watermark="Find Movies, TV Series, Games, and more..."
                  IsEditable="True"
                  MaxDropDownHeight="100"
                  DisplayMemberPath="Title"
                  SelectedItem="{Binding SelectedImdbTitle, Mode=TwoWay}"
                  Width="500"
                  Height="22" />
        <Grid Margin="0"
              Grid.Row="1"
              Visibility="{Binding DetailsVisibility}">
            <GroupBox Header="{Binding SelectedImdbTitle.Title}"
                      HorizontalAlignment="Stretch"
                      VerticalAlignment="Stretch">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="320" />
                        <RowDefinition Height="75"/>
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <StackPanel Margin="0"
                                Orientation="Horizontal"
                                VerticalAlignment="Top">

                        <Grid Height="300">
                            <Image HorizontalAlignment="Left"
                                   VerticalAlignment="Top"
                                   Source="{Binding SelectedImdbTitle.Poster, Converter={StaticResource LocalPosterUrl}}"
                                   Width="200"
                                   Height="300" />
                        </Grid>

                        <StackPanel>

                            <StackPanel Orientation="Horizontal">
                                <GroupBox Header="Type"
                                          HorizontalAlignment="Left"
                                          VerticalAlignment="Top"
                                          Width="120">
                                    <Grid>
                                        <TextBlock Text="{Binding Type}"
                                                   FontSize="14"
                                                   FontFamily="Segeo UI Light" />
                                    </Grid>
                                </GroupBox>

                                <GroupBox Header="Year"
                                          HorizontalAlignment="Left"
                                          VerticalAlignment="Top"
                                          Width="120">
                                    <Grid>
                                        <TextBlock Text="{Binding SelectedImdbTitle.Year}"
                                                   FontSize="14"
                                                   VerticalAlignment="Center"
                                                   HorizontalAlignment="Center"
                                                   FontFamily="Segeo UI Light" />
                                    </Grid>
                                </GroupBox>

                                <GroupBox Header="Rating"
                                          HorizontalAlignment="Left"
                                          VerticalAlignment="Top"
                                          Width="370">
                                    <Grid>
                                        <StackPanel Orientation="Horizontal">
                                            <ProgressBar Maximum="10"
                                                         Width="100"
                                                         Value="{Binding SelectedImdbTitle.Rating}"
                                                         Margin="0,0,5,0" />
                                            <TextBlock Text="{Binding Rating}"
                                                       FontSize="14"
                                                       FontFamily="Segeo UI Light" />
                                        </StackPanel>
                                    </Grid>
                                </GroupBox>

                                <GroupBox Header="Run time"
                                          HorizontalAlignment="Left"
                                          VerticalAlignment="Top"
                                          Width="120">
                                    <Grid>
                                        <TextBlock Text="{Binding RunTime}"
                                                   FontSize="14"
                                                   VerticalAlignment="Center"
                                                   HorizontalAlignment="Center"
                                                   FontFamily="Segeo UI Light" />
                                    </Grid>
                                </GroupBox>


                            </StackPanel>

                            <StackPanel Orientation="Horizontal">

                                <StackPanel>

                                    <GroupBox Header="Language"
                                              HorizontalAlignment="Left"
                                              VerticalAlignment="Top"
                                              Height="110"
                                              Width="120">
                                        <Grid>
                                            <ListBox ItemsSource="{Binding SelectedImdbTitle.Language}">
                                                <ListBox.ItemTemplate>
                                                    <DataTemplate>
                                                        <TextBlock Text="{Binding}"
                                                                   FontSize="14"
                                                                   FontFamily="Segeo UI Light" />
                                                    </DataTemplate>
                                                </ListBox.ItemTemplate>
                                            </ListBox>
                                        </Grid>
                                    </GroupBox>

                                    <GroupBox Header="Genre"
                                              HorizontalAlignment="Left"
                                              VerticalAlignment="Top"
                                              Height="120"
                                              Width="120">
                                        <Grid>
                                            <ListBox ItemsSource="{Binding SelectedImdbTitle.Genres}">
                                                <ListBox.ItemTemplate>
                                                    <DataTemplate>
                                                        <TextBlock Text="{Binding}"
                                                                   FontSize="14"
                                                                   FontFamily="Segeo UI Light" />
                                                    </DataTemplate>
                                                </ListBox.ItemTemplate>
                                            </ListBox>
                                        </Grid>
                                    </GroupBox>

                                </StackPanel>

                                <StackPanel>

                                    <GroupBox Header="Country"
                                              HorizontalAlignment="Left"
                                              VerticalAlignment="Top"
                                              Height="110"
                                              Width="120">
                                        <Grid>
                                            <ListBox ItemsSource="{Binding SelectedImdbTitle.Country}">
                                                <ListBox.ItemTemplate>
                                                    <DataTemplate>
                                                        <TextBlock Text="{Binding}"
                                                                   FontSize="14"
                                                                   FontFamily="Segeo UI Light" />
                                                    </DataTemplate>
                                                </ListBox.ItemTemplate>
                                            </ListBox>
                                        </Grid>
                                    </GroupBox>

                                    <GroupBox Header="Release Date"
                                              HorizontalAlignment="Left"
                                              VerticalAlignment="Top"
                                              Width="120">
                                        <Grid>
                                            <TextBlock Text="{Binding SelectedImdbTitle.ReleaseDate, Converter={StaticResource ImdbDateToDateTime}}"
                                                       FontSize="14"
                                                       VerticalAlignment="Center"
                                                       HorizontalAlignment="Center"
                                                       FontFamily="Segeo UI Light" />
                                        </Grid>
                                    </GroupBox>

                                    <GroupBox Header="Imdb Id"
                                              HorizontalAlignment="Left"
                                              VerticalAlignment="Top"
                                              Width="120">
                                        <Grid>
                                            <TextBlock Text="{Binding SelectedImdbTitle.ImdbId, Converter={StaticResource StringUpperCase}}"
                                                       FontSize="14"
                                                       VerticalAlignment="Center"
                                                       HorizontalAlignment="Center"
                                                       FontFamily="Segeo UI Light" />
                                        </Grid>
                                    </GroupBox>

                                </StackPanel>

                                <GroupBox Header="Actors"
                                          HorizontalAlignment="Left"
                                          VerticalAlignment="Top"
                                          Height="240"
                                          Width="180">
                                    <Grid>
                                        <ListBox ItemsSource="{Binding SelectedImdbTitle.Actors}">
                                            <ListBox.ItemTemplate>
                                                <DataTemplate>
                                                    <TextBlock Text="{Binding}"
                                                               FontSize="14"
                                                               FontFamily="Segeo UI Light" />
                                                </DataTemplate>
                                            </ListBox.ItemTemplate>
                                        </ListBox>
                                    </Grid>
                                </GroupBox>

                                <StackPanel>

                                    <GroupBox Header="Directors"
                                              HorizontalAlignment="Left"
                                              VerticalAlignment="Top"
                                              Height="110"
                                              Width="180">
                                        <Grid>
                                            <ListBox ItemsSource="{Binding SelectedImdbTitle.Directors}">
                                                <ListBox.ItemTemplate>
                                                    <DataTemplate>
                                                        <TextBlock Text="{Binding}"
                                                                   FontSize="14"
                                                                   FontFamily="Segeo UI Light" />
                                                    </DataTemplate>
                                                </ListBox.ItemTemplate>
                                            </ListBox>
                                        </Grid>
                                    </GroupBox>

                                    <GroupBox Header="Writers"
                                              HorizontalAlignment="Left"
                                              VerticalAlignment="Top"
                                              Height="120"
                                              Width="180">
                                        <Grid>
                                            <ListBox ItemsSource="{Binding SelectedImdbTitle.Writers}">
                                                <ListBox.ItemTemplate>
                                                    <DataTemplate>
                                                        <TextBlock Text="{Binding}"
                                                                   FontSize="14"
                                                                   FontFamily="Segeo UI Light" />
                                                    </DataTemplate>
                                                </ListBox.ItemTemplate>
                                            </ListBox>
                                        </Grid>
                                    </GroupBox>
                                </StackPanel>

                                <GroupBox Header="Plot/Summary/Synopsis"
                                          HorizontalAlignment="Left"
                                          VerticalAlignment="Stretch"
                                          Width="400"
                                          Height="240">
                                    <Grid>
                                        <ScrollViewer>
                                            <TextBlock Text="{Binding SelectedImdbTitle.Plot}"
                                                       FontSize="15"
                                                       TextAlignment="Justify"
                                                       FontWeight="Light"
                                                       TextWrapping="Wrap" />
                                        </ScrollViewer>
                                    </Grid>
                                </GroupBox>
                            </StackPanel>
                        </StackPanel>
                    </StackPanel>

                    <GroupBox Header="Filming Locations"
                              Grid.Row="1"
                              HorizontalAlignment="Stretch"
                              VerticalAlignment="Stretch">
                        <Grid >
                            <TextBlock Text="{Binding SelectedImdbTitle.FilmingLocations}"
                                       FontSize="14"
                                       FontFamily="Segeo UI Light" />
                        </Grid>
                    </GroupBox>

                    <GroupBox Header="Seasons"
                              Grid.Row="2"
                              Visibility="{Binding EpisodesVisibility}"
                              HorizontalAlignment="Stretch"
                              VerticalAlignment="Stretch">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="200"/>
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>

                            <ListBox ItemsSource="{Binding Seasons}"
                                     SelectedItem="{Binding SelectedSeason, Mode=TwoWay}">
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <TextBlock>
                                            <Run Text="Season "/>
                                            <Run Text="{Binding Mode=OneWay}" />
                                        </TextBlock>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>

                            <ListBox ItemsSource="{Binding Episodes}"
                                     Grid.Column="1">
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <TextBlock>
                                            <Run Text="Episode -" />
                                            <Run Text="{Binding EpisodeSL}" />
                                            <Run Text="-" />
                                            <Run Text="{Binding Title}" />
                                        </TextBlock>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>

                        </Grid>
                    </GroupBox>

                </Grid>
            </GroupBox>
        </Grid>

    </Grid>
</UserControl>
